export default {
    namespaced: true,
    state: {
        // Chats module on top search input
        chatsSearchText: '',
        curRoutePath: '',
        // user
        curFriendUserInfo: null,
        curGroupInfo: null,
        curGroupMembers: null,
        // chat-conversation info
        curChatConversation: null,
        // control ChatConversation component is show
        isShowChatConversation: false
    },
    mutations: {
        setChatsSearchText(state, newVal) {
            state.chatsSearchText = newVal
        },
        setCurRoutePath(state, newVal) {
            state.curRoutePath = newVal
        },
        setCurFriendUserInfo(state, newVal) {
            state.curFriendUserInfo = newVal
        },
        setCurGroupInfo(state, newVal) {
            state.curGroupInfo = newVal
        },
        setCurGroupMembers(state, newVal) {
            state.curGroupMembers = newVal
        },
        setCurChatConversation(state, newVal) {
            state.curChatConversation = newVal
        },
        setIsShowChatConversation(state, newVal) {
            state.isShowChatConversation = newVal
        },
    },
    actions: {
        updateChatsSearchText({commit}, newValue) {
            commit("setChatsSearchText", newValue); // mutation update data
        },
        updateCurRoutePath({commit}, newVal) {
            commit("setCurRoutePath", newVal)
        },
        updateCurFriendUserInfo({commit}, newVal) {
            commit("setCurFriendUserInfo", newVal)
        },
        updateCurGroupInfo({commit}, newVal) {
            commit("setCurGroupInfo", newVal)
        },
        updateCurGroupMembers({commit}, newVal) {
            commit("setCurGroupMembers", newVal)
        },
        updateCurChatConversation({commit}, newVal) {
            commit("setCurChatConversation", newVal)
        },
        updateIsShowChatConversation({commit}, newVal) {
            commit("setIsShowChatConversation", newVal)
        },
    },
    getters: {
        getChatsSearchText: (state) => state.chatsSearchText,
        getCurRoutePath: (state) => state.curRoutePath,
        getCurFriendUserInfo: (state) => state.curFriendUserInfo,
        getCurGroupInfo: (state) => state.curGroupInfo,
        getCurGroupMembers: (state) => state.curGroupMembers,
        getCurChatConversation: (state) => state.curChatConversation,
        getIsShowChatConversation: (state) => state.isShowChatConversation,
    }
}